package com.admin.controller.miniprogram;

import com.admin.controller.admin.upload.ArticleVo;
import com.system.response.Result;
import com.system.service.miniprogram.upload.UploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


@RestController
@RequestMapping("/app/qiniu")
public class uploadController {
    @Autowired
    private UploadService uploadService;

    @PostMapping("/upload")
    public Result resource(@RequestParam("files") MultipartFile[] files) {
        return uploadService.uploadImageToQiniu(files);
    }

    @DeleteMapping("/delete")
    public Result qiniuDelete(@RequestParam("fileName") String fileName) {
        return uploadService.deleteImageAndQiniu(fileName);
    }

    @PostMapping("/issueArticle")
    public Result issueArticle(@RequestBody ArticleVo article){
        System.out.println("article = " + article);
        return new Result().setCode(200).setData(article);
    }
}
